3 This is the unit test runner for AppleScript. In order to run them from the command line, in adium/ folder, use
4 osascript unittest\ runner.applescript
8 For some reason, Script Editor doesn't like the pipe character...
10 Anyway, this will compile and run the AppleScripts in ASUnitTests and report the results. The tr translates the old Mac CR to Unix LF. You should see Adium leap about while this is happening. Every unit test should clean up after itself, so that no windows are left lying around, extra accounts existing, etc.
12 The runner will report if any tests failed and the error number and message. It will also summarize with a number succeeded out of the total number.
15 property unitTestDir :
"ASUnitTests/"
17 script HandyAdiumScripts
18 property defaultService :
"AIM"
19 property defaultAccount :
"applmak"
20 property defaultParticipant :
"applmak"
21 property otherParticipant :
"boredzo"
22 on makeTemporaryAccount()
23 tell application "Adium"
24 tell service defaultService
25 return make new account
with properties {
title:
"test"}
28 end makeTemporaryAccount
29 on makeNewChatWindow()
30 tell application "Adium"
31 set newChat
to my makeNewChat()
32 return (
get window of newChat)
36 tell application "Adium"
37 tell account defaultAccount
38 set newChat
to make new chat
with contacts {
my findSomeParticipant()}
with new chat
window
43 on findSomeParticipant()
44 tell application "Adium"
45 tell account defaultAccount
46 if exists contact defaultParticipant
then
47 return contact defaultParticipant
49 if (
count contacts) >
1 then
53 error "Can't get any contacts because account is offline."
59 end findSomeParticipant
61 tell application "Adium"
62 repeat while exists chat
window 1
70 --compile the .applescript files
71 do shell
script "for i in " & quoted form
of unitTestDir &
"*.applescript; do s=`basename $i .applescript`; osacompile -o " & quoted form
of unitTestDir &
"/${s}.scpt " & quoted form
of unitTestDir &
"/${s}.applescript ; done;"
72 --get contents of unitTestDir
73 tell application "Finder"
74 set unittestScripts
to every file of folder ((POSIX
file unitTestDir)
as text)
whose name extension
is "scpt"
76 set successReport
to ""
79 set startTime
to current date
80 repeat with s
in unittestScripts
81 set nameOfS
to (
get name of s)
82 --do any set up or takedown
83 --For speed concerns, I'm going to assume that a unit test will do these
85 set unittest
to load script file ((((POSIX
file unitTestDir)
as text) & nameOfS))
87 set total
to total +
1
89 set successReport
to successReport & nameOfS &
": Success!" &
return
90 on error msg
number num
91 set failed
to failed +
1
94 set report
to report & nameOfS &
": " &
"Assertion Failed: " & num &
": " & msg &
return
97 set report
to report & nameOfS &
": " &
"Unexpected Exception: " & num &
": " & msg &
return
101 set report
to report & nameOfS &
": " &
"Error Loading Script!" &
return
105 set report
to "Number Of Successes/Total: " & (total - failed) &
"/" & total &
return &
"Time: " & ((
current date) - startTime) &
"s" &
return & report &
"-----" &
return & successReport